package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.historyRFCPanel.historyRFCPanelSubs.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.controller.historyRFC.LoadHistoryThread;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.model.User;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.historyRFCPanel.HistoryRFCPanel;

public class LoadHistoryButtonListener implements ActionListener
{
	private HistoryRFCPanel historyRFCPanel;
	private LoadHistoryThread loadHistoryThread;
	private User signedInUser;
	
	public LoadHistoryButtonListener(HistoryRFCPanel historyRFCPanel)
	{
		this.historyRFCPanel = historyRFCPanel;
		this.signedInUser = historyRFCPanel.getMainframe().getSignedInUser();
	}

	public void actionPerformed(ActionEvent arg0)
	{
		this.loadHistoryThread = new LoadHistoryThread(this.historyRFCPanel, this.signedInUser);
		this.historyRFCPanel.getHistoryRFCFunctionPanel().getProgress().setVisible(true);
		this.loadHistoryThread.start();
		this.historyRFCPanel.getHistoryRFCFunctionPanel().getProgress().setVisible(false);
	}
}